//
//  MSCommentHeaderView.m
//  MSJD
//
//  Created by xiangbo on 2018/12/3.
//  Copyright © 2018 xiangbo. All rights reserved.
//

#import "MSCommentHeaderView.h"

@implementation MSCommentHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupSubviews];
    }
    return self;
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupSubviews];
    }
    return self;
}

- (void)setupSubviews{
    self.contentView.backgroundColor = [UIColor whiteColor];
    self.descLabel = [[UILabel alloc] init];
    self.descLabel.text = @"精彩点评";
    self.descLabel.font = [UIFont systemFontOfSize:16];
    self.descLabel.textColor = UIColorHex(0x444444);
    [self.contentView addSubview:self.descLabel];
    
    self.commentButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.commentButton.titleLabel.textColor = UIColorHex(0xffffff);
    [self.commentButton setTitle:@"我要点评" forState:UIControlStateNormal];
    [self.commentButton setBackgroundColor:UIColorHex(0xF96332)];
    self.commentButton.titleLabel.font = [UIFont systemFontOfSize:14];
    self.commentButton.layer.cornerRadius = 14.f;
    self.commentButton.hidden = YES;
    [self.contentView addSubview:self.commentButton];
    
    [self.commentButton addTarget:self action:@selector(commentAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.lineView = [[UIView alloc] init];
    [self.contentView addSubview:self.lineView];
    self.lineView.backgroundColor = MSSubTitleColor;
    self.lineView.hidden = YES;
    
    [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20.f);
        make.top.mas_equalTo(24.f);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(22);
    }];
    
    [self.commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.descLabel);
        make.right.equalTo(self).offset(-20);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(28);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.bottom.equalTo(self);
        make.height.mas_equalTo(0.5);
    }];
}


- (void)commentAction:(id)sender{
    [self routerEventWithName:kCommentButtonClicked userInfo:nil];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
